home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / C / Applications / UIFlow 1.0.1 / UIFlow Source / VSet2.0 / Src / vhi.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-04-20  |  3.0 KB  |  128 lines  |  [TEXT/????]

  1. /* 
  2. * ============================================
  3. * VHxxx  routines:
  4. * HDF Vset high-level access routines
  5. * 28-MAR-91 Jason Ng NCSA
  6. * ============================================
  7. */
  8.  
  9. #include "vg.h"
  10.  
  11. /* ------------------------------------------------------------------ */
  12. /*
  13. Stores 'n' elements of data from 'buf' as a
  14. field 'field' in a new vdata called 'vsname' into the
  15. already opened HDF file (with pointer 'f').
  16.  
  17. The datatype variable must be specified as one of:
  18. LOCAL_FLOATTYPE, LOCAL_INTTYPE, LOCAL_LONGTYPE, LOCAL_CHARTYPE.
  19.  
  20. NOTES:
  21. n should not be zero or negative.
  22. RETURN:
  23. -1 if error.
  24. ref of that new vdata (a +ve integer) if successful.
  25. Need to check if field already defined
  26. */
  27.  
  28. PUBLIC int VHstoredata (f, field, buf, n, datatype, vsname, vsclass)
  29. DF * f;
  30. char * field;
  31. unsigned char buf[];
  32. int32 n;
  33. char * vsname, * vsclass;
  34. int datatype;
  35. {
  36.     int ref;
  37.     int order = 1;
  38.  
  39.  
  40.     ref=  VHstoredatam (f, field, buf, n, datatype,  vsname, vsclass, order);
  41.  
  42.     return(ref);
  43. }
  44.  
  45. /* ------------------------------------------------------------------ */
  46. /*
  47. Same as VHstoredata but allows aggregate-typed field.
  48. Stores 'n' elements of data from 'buf' as a
  49. field 'field' in a new vdata called 'vsname' into the
  50. already opened HDF file (with pointer 'f').
  51.  
  52. The datatype variable must be specified as one of:
  53. LOCAL_FLOATTYPE, LOCAL_INTTYPE, LOCAL_LONGTYPE, LOCAL_CHARTYPE.
  54.  
  55. NOTES:
  56. n should not be zero or negative.
  57. RETURN:
  58. -1 if error.
  59. ref of that new vdata (a +ve integer) if successful.
  60. Need to check if field already defined
  61. */
  62.  
  63. PUBLIC int VHstoredatam (f, field, buf, n, datatype, vsname, vsclass, order)
  64. DF     *f;
  65. char     *field;
  66. unsigned char buf[];
  67. int32 n;
  68. int     datatype;
  69. int     order;
  70. char *vsname, *vsclass;
  71. {
  72.     int     s;
  73.     int ref;
  74.     VDATA *vs;
  75.  
  76.     vs = (VDATA*) VSattach (f,-1,"w");          if (vs==NULL) return (-1);
  77.     s = VSfdefine (vs, field, datatype, order); if (s == -1) return (-1);
  78.     s = VSsetfields (vs,field);                 if (s == -1) return (-1);
  79.     s = VSwrite (vs, buf, n, FULL_INTERLACE);      if (n != s)  return (-1);
  80.     VSsetname (vs, vsname);
  81.     VSsetclass(vs, vsclass);
  82.     ref = vs->oref;
  83.     VSdetach(vs);
  84.     return(ref);
  85.  
  86. } /* VHstoredatam */
  87.  
  88. /* ------------------------------------------------------------------ */
  89. /* 
  90. Takes an array of tags and and array of refs and create a vgroup to
  91. store them. You tell it how many tag/ref pairs there are. You must 
  92. also give the vgroup a name.
  93. NOTE:
  94. Does bot check if a tag/ref is valid or exist, but ALL tag/ref 
  95. pairs MUST be unique.
  96. Creating EMPTY vgroups is allowed.
  97.  
  98. RETURN: 
  99. -1 if error
  100. ref of the new vgroup (a +ve integre) if ok.
  101. */
  102.  
  103. PUBLIC int VHmakegroup (f, tagarray, refarray , n, vgname, vgclass)
  104. DF * f;
  105. int tagarray[], refarray[];
  106. int n;
  107. char     *vgname, *vgclass;
  108. {
  109.     int ref, i, s;    
  110.     VGROUP *vg;
  111.  
  112.     vg = (VGROUP*) Vattach (f, -1, "w"); if (vg==NULL) return (-1);
  113.     Vsetname (vg, vgname);
  114.     Vsetclass(vg, vgclass);
  115.  
  116.     for (i=0; i<n; i++) {
  117.         s = Vaddtagref (vg, tagarray[i], refarray[i]);
  118.         if (s == -1) return (-1);
  119.         }
  120.  
  121.     ref = vg->oref;
  122.     Vdetach (vg);
  123.     return (ref);
  124.  
  125. } /* VHmakegroup */
  126.  
  127. /* ------------------------------------------------------------------ */
  128.